<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function People(name, age) {
            this.name = name;
            this.age = age;
            // this.sing = function() {
            //     console.log('我会唱歌');
            // }
        }
        People.prototype.sing = function() {
            console.log('hello');
        }
        var ldh = new People('ldh', 17);
        var zxy = new People('zxy', 18);
        // 如果两个实例对象调用sing方法，内存会开辟两个空间存放不同对象的sing()
        // 这样我们会浪费空间，就把他放入原型对象里,共享方法
        ldh.sing();
        zxy.sing();
        // 找到原型的构造函数
        console.log(People.prototype.constructor);
    </script>
</body>
</html>